home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
basic
/
EFMUILibSrc.lha
/
EFMUILibSrc
/
cln.asc
next >
Wrap
Text File
|
1998-02-03
|
4KB
|
197 lines
;cln.bb2 --- ChangeLibNumber
;
;(c) 1997/98 Vivid Imagination
Dim *args.b(6)
rdargs.l=ReadArgs_("LIB/A,NUM/A/N,MINNUM/K/N,MAXNUM/K/N,QUIET/S,FIXEDNUM/S",&*args(0),0)
If rdargs=0
End
EndIf
wlibname$=LCase$(Peek$(*args(0)))
wlibnum.l=Peek.l(*args(1))
minnum.l=Peek.l(*args(2))
maxnum.l=Peek.l(*args(3))
noreq.b=*args(4)
fix.b=*args(5)
If (minnum >= maxnum) OR (minnum < 0) OR (maxnum <=0) OR (minnum >= 256) OR (maxnum > 256)
minnum=2
maxnum=40
EndIf
FreeArgs_ rdargs
NEWTYPE.lib
name$
num.w
rname$
End NEWTYPE
#maxlibs=200
Dim libs.lib(#maxlibs)
nl.l=-1
DEFTYPE.lib temp
DEFTYPE.b num
DEFTYPE.l
l.l=Lock_("blitzlibs:",-2)
If l=0
If noreq=False
NPrint "Fatal Error : Can't lock 'blitzlibs:'"
EndIf
End
EndIf
*fib.FileInfoBlock=AllocMem_(SizeOf.FileInfoBlock,#MEMF_PUBLIC)
*fib2.FileInfoBlock=AllocMem_(SizeOf.FileInfoBlock,#MEMF_PUBLIC)
Examine_ l,*fib
While ExNext_(l,*fib)
If *fib\fib_DirEntryType>=0 ;dir ?
d$="blitzlibs:"+Peek$(&*fib\fib_FileName)
l2.l=Lock_(&d$,-2)
If l2=0
If noreq=False
NPrint "Fatal Error : Can't lock '",d$,"'"
EndIf
UnLock_ l
FreeMem_ *fib,SizeOf.FileInfoBlock:FreeMem_ *fib2,SizeOf.FileInfoBlock
End
EndIf
Examine_ l2,*fib2
While ExNext_(l2,*fib2)
If *fib2\fib_DirEntryType<0 ;file?
nf$=LCase$(Peek$(&*fib2\fib_FileName))
If Right$(nf$,5)<>".info"
f$=d$+"/"+nf$
If ReadFile(0,f$)
Fields 0,num
num=0
nl+1
FileInput 0
If Right$(nf$,4)=".obj"
libs(nl)\name=LCase$(UnLeft$(nf$,4))
Else
ex=Instr(nf$,".")
libs(nl)\name=LCase$(Left$(nf$,ex-1))+"lib"
EndIf
Get 0,37
If num<0
libs(nl)\num=num+256
Else
libs(nl)\num=num
EndIf
libs(nl)\rname=f$
CloseFile 0
Else
If noreq=False
NPrint "Fatal Error : Can't read file '",f$,"'"
EndIf
UnLock_ l:UnLock_ l2
FreeMem_ *fib,SizeOf.FileInfoBlock:FreeMem_ *fib2,SizeOf.FileInfoBlock
End
EndIf
EndIf
EndIf
Wend
UnLock_ l2
EndIf
Wend
DefaultInput
UnLock_ l
FreeMem_ *fib,SizeOf.FileInfoBlock:FreeMem_ *fib2,SizeOf.FileInfoBlock
wrname$=""
For i=0 To nl
If libs(i)\name=wlibname$
wrname$=libs(i)\rname
If libs(i)\num=wlibnum
If noreq=False
NPrint "Warning : No need to change the number"
EndIf
End
EndIf
EndIf
Next
If wrname$=""
If noreq=False
NPrint "Error : The library doesn't exist in 'blitzlibs:'"
EndIf
End
EndIf
libn=minnum
cln.b=False
lab1
For i=0 To nl
If libs(i)\num=wlibnum
If fix=True
If noreq=False
NPrint "Error : Library number already used"
NPrint "Please compile that lib changing the number"
EndIf
End
EndIf
cln=True
wlibnum=libn
libn+1
If libn > maxnum
If noreq=False
NPrint "Error : Unable to find a usable number"
EndIf
End
EndIf
Pop For
Goto lab1
EndIf
Next
If noreq=False
If cln=True
NPrint "New number : ",wlibnum
EndIf
EndIf
num.b=wlibnum
If OpenFile(0,wrname$)
FileSeek 0,0
Fields 0,num.b
Put 0,37
CloseFile 0
Else
If noreq=False
NPrint "Fatal Error : Can't open the library"
EndIf
End
EndIf
If noreq=False
NPrint "Success"
EndIf
End